package com.leantech.android.browser

import android.app.Application
import com.lean.android.ad.core.AdSdk
import com.lean.android.ad.core.config.AdConfig
import com.lean.android.ad.core.config.AdParamsProvider
import com.lean.android.ad.core.config.AppInfoProvider
import com.lean.android.ad.core.config.ChannelInfoProvider
import com.lean.android.ad.core.config.RewardCustomFloatView
import com.lean.android.ad.core.splash.SplashAdView
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

class AdInitial : KoinComponent {

    private val umengKey = getKoin().getProperty("umengKey", "")

    private val appInfoProvider by inject<AppInfoProvider>()

    private val adParamsProvider by inject<AdParamsProvider>()

    private val splashAdView by inject<SplashAdView>()

    private val rewardCustomFloatView by inject<RewardCustomFloatView>()

    private val channelProvider by inject<ChannelInfoProvider>()

    fun init(app: Application) {
        AdSdk.isVip = true
        AdSdk.init(
            app, AdConfig(
                appInfoProvider = appInfoProvider,
                adParamsProvider = adParamsProvider,
                splashAdView = splashAdView,
                rewardCustomFloatView = rewardCustomFloatView,
                channelInfoProvider = channelProvider,
                umengAppKey = umengKey,
                accessPem = "${BuildConfig.APPLICATION_ID}.cert.pem",
            )
        )
    }
}